package de.tto.dating.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

public class AbstractEntity implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5727242513183963016L;
	
	public static final String CREATED_OID = "oid";
	public static final String CREATED_DATE = "createdDate";
	public static final String CHANGED_DATE = "changedDate";
	public static final String CREATED_BY = "createdBy";
	public static final String CHANGED_BY = "changedBy";

	@Id
	private Long oid;

	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	@Temporal(TemporalType.TIMESTAMP)
	private Date changedDate;

	private Long createdBy;

	private Long changedBy;

	@PrePersist
	public void prePersist() {
		if (createdDate == null) {
			createdDate = new Date();
		}
		changedDate = new Date();
	}

	/**
	 * @param createdDate
	 *            the createdDate to set
	 */
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	/**
	 * @return the createdDate
	 */
	public Date getCreatedDate() {
		return createdDate;
	}

	/**
	 * @param changedDate
	 *            the changedDate to set
	 */
	public void setChangedDate(Date changedDate) {
		this.changedDate = changedDate;
	}

	/**
	 * @return the changedDate
	 */
	public Date getChangedDate() {
		return changedDate;
	}

	/**
	 * @param createdBy
	 *            the createdBy to set
	 */
	public void setCreatedBy(Long createdBy) {
		this.createdBy = createdBy;
	}

	/**
	 * @return the createdBy
	 */
	public Long getCreatedBy() {
		return createdBy;
	}

	/**
	 * @param changedBy
	 *            the changedBy to set
	 */
	public void setChangedBy(Long changedBy) {
		this.changedBy = changedBy;
	}

	/**
	 * @return the changedBy
	 */
	public Long getChangedBy() {
		return changedBy;
	}

	/**
	 * @param oid
	 *            the oid to set
	 */
	public void setOid(Long oid) {
		this.oid = oid;
	}

	/**
	 * @return the oid
	 */
	public Long getOid() {
		return oid;
	}

}
